﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="hrImportGJJ.aspx.cs" Inherits="ZX.WebApp.EHR.hrImportGJJ" %>
<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>

<%@ Register assembly="DevExpress.Web.v11.2, Version=11.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxUploadControl" tagprefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>公积金导入</title>
     <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
     <script type="text/javascript">
    // <![CDATA[
         var fieldSeparator = "|";
         var _fileName = "";
         function TempletDownload() {
             var linkFile = document.createElement("a");
             var date = new Date();
             var imgSrc = "../upload/EHR/公积金导入模板.xls?dx=" + date.getTime();
             linkFile.innerHTML = "公积金导入模板";
             linkFile.setAttribute("href", imgSrc);
             linkFile.setAttribute("target", "_blank");
             var container = document.getElementById("divTemplet");
             container.appendChild(linkFile);
         }

         function FileUploadStart() {
             document.getElementById("uploadedListFiles").innerHTML = "";
         }
         function FileUploaded(s, e) {
             if (e.isValid) {
                 var linkFile = document.createElement("a");
                 var indexSeparator = e.callbackData.indexOf(fieldSeparator);
                 var fileName = e.callbackData.substring(0, indexSeparator);
                 var pictureUrl = e.callbackData.substring(indexSeparator + fieldSeparator.length);
                 _fileName = pictureUrl;
                 var date = new Date();
                 var imgSrc = "../upload/EHR/" + pictureUrl + "?dx=" + date.getTime();
                 linkFile.innerHTML = fileName;
                 linkFile.setAttribute("href", imgSrc);
                 linkFile.setAttribute("target", "_blank");
                 var container = document.getElementById("uploadedListFiles");
                 container.appendChild(linkFile);
                 container.appendChild(document.createElement("br"));
                 var h = container.clientHeight + 15;
                 container.style.height = h + "px";
             }
         }

         $(document).ready(function () {
             parent.document.getElementById("dialog1_h").innerHTML = "公积金导入";
             $("#spMsg").hide();
             TempletDownload();
         });

         //数据保存
         function Save() {
             parent.$("#yui-gen7-button").attr("disabled", true);
             $("#spMsg").show().text("正在导入，请稍等....");
             //parent.$("#yui-gen7-button").css("background", "whitesmoke");
             //提交数据
             YAHOO.util.Connect.asyncRequest('POST', "hrImportGJJ.aspx?flag=save", {
                 success: function (res) {
                     try {
                         var str = res.responseText;
                         if (str.substring(0, 1) == "1") {
                             alert("数据保存成功!");
                             parent.closeWin();
                             parent.ReLoadData();
                         }
                         else {
                             alert(str);
                             $("#spMsg").hide();
                             parent.$("#yui-gen7-button").removeAttr("disabled");
                         }
                     }
                     catch (e) {
                     }
                     finally {
                     }
                 },
                 failure: function (error) {
                     //debugger;
                     alert("数据错误：" + error.responseText);
                     FileUploadStart();
                     $("#spMsg").hide();
                     parent.$("#yui-gen7-button").removeAttr("disabled");
                     //parent.$("#yui-gen7-button").removeClass("background");
                 }
             }, null);
         }
    // ]]> 
     </script>
</head>
<body>
    <form id="form1" runat="server">
    <br />
    <table style="font-family: 宋体, Arial, Helvetica, sans-serif; font-size: small">
      <tr>
        <td>&nbsp;&nbsp;</td>
        <td>
          <div id="tishixinxi" style="color:Red"></div>
            <div id="divTemplet" style="height: 10px; font-family: Arial;"></div>
        </td>
      </tr>
      <tr>
         <td>&nbsp;&nbsp;</td>
         <td>
           <dx:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" Width="400px" ClientInstanceName="RoundPanel" HeaderText="五险一金数据文件列表" Height="100%">
                  <PanelCollection>
                    <dx:PanelContent>
                        <div id="uploadedListFiles" style="height: 10px; font-family: Arial;"></div>
                    </dx:PanelContent>
                  </PanelCollection>        
              </dx:ASPxRoundPanel>
         </td>
      </tr>
      <tr>
        <td>&nbsp;&nbsp;</td>
        <td>
          <div>
            <dx:ASPxUploadControl ID="UploadControl" runat="server" ShowAddRemoveButtons="True"
                    Width="400px" ShowUploadButton="True" AddUploadButtonsHorizontalPosition="Center"
                    ShowProgressPanel="True" ClientInstanceName="UploadControl" 
                  OnFileUploadComplete="UploadControl_FileUploadComplete" 
                  ClearFileSelectionImage-AlternateText="清除" ValidationSettings-AllowedFileExtensions=".xls,.xlsx">
                    <ValidationSettings AllowedFileExtensions=".xls,.xlsx" 
                        NotAllowedFileExtensionErrorText="不允许上传该类型文件！">
                    </ValidationSettings>
                    <ClientSideEvents FileUploadComplete="function(s, e) { FileUploaded(s, e) }" FileUploadStart="function(s, e) { FileUploadStart(); }" />
                    <AddButton Text="添加文件"></AddButton>
                    <BrowseButton Text="浏览..."></BrowseButton>
                    <RemoveButton Text="移除"></RemoveButton>
                    <UploadButton Text="上传文件"></UploadButton>
                    <CancelButton Text="取消"></CancelButton>
                    <ClearFileSelectionImage AlternateText="清除" ToolTip="清除"></ClearFileSelectionImage>
                </dx:ASPxUploadControl>
             </div>
         </td>
      </tr>
      <tr>
        <td colspan="2"><span id="spMsg">msg</span> </td>
      </tr>
    </table>        
    </form>
</body>
</html>
